package com.hongyuan.venue.ui.home.view_mode;

import android.app.Application;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.venue.base.CustomViewModel;
import com.hongyuan.venue.data.Constants;
import com.hongyuan.venue.data.MyRepository;
import com.hongyuan.venue.ui.home.activity.TrainningPayActivity;
import com.hongyuan.venue.ui.home.beans.TrainningDetailBeans;

public class TrainningDetailsDetailViewModel extends CustomViewModel<MyRepository> {

    public ObservableField<TrainningDetailBeans> entity = new ObservableField<>();

    public TrainningDetailsDetailViewModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }


    //去确认支付
    public BindingCommand goSubmit = new BindingCommand(() -> {
        Bundle bundle = new Bundle();
        bundle.putSerializable("details",entity.get());
        startActivity(TrainningPayActivity.class,bundle);
    });

    @Override
    protected void returnData(int code, Object dataBean) {
        super.returnData(code, dataBean);

        if(code == Constants.COURSE_TRAIN_DETAIL){
            TrainningDetailBeans bean = (TrainningDetailBeans)dataBean;
            entity.set(bean);
        }
    }
}
